/* 
    导入less
*/
// 重置样式
require("../css/commCss/normalize.css");
// 补充重置样式
require("../css/commCss/reset.css");
// 属性样式
require("../css/commCss/property.css");
// 基础样式
require("../css/commCss/basic.css");

// 字体样式
require("../fonts/iconfont.css");

// 当前样式
require("../css/mine.less");

// 获取axios
const axios = require("axios");

// 获取weui
require("weui");
const weui = require("weui.js");

// 获取元素
const nickname = document.querySelector("#nickname");
const imgurl = document.querySelector("#imgurl");
const sign = document.querySelector("#sign");
const dynamicCount = document.querySelector("#dynamicCount");
const times = document.querySelector("#times");
const calorie = document.querySelector("#calorie");
const loginOut = document.querySelector("#loginOut");
const information = document.querySelector('#information')
const userId = localStorage.getItem("userId");
// console.log(userId);

// 发送用户信息axios请求
axios
  .get("http://139.9.177.51:8099/users/accountinfo?userId=" + userId)
  .then(function (res) {
    // console.log(res.data);

    if (res.data.status === 0) {
      if (res.data.data.nickname) {
        nickname.textContent = res.data.data.nickname;
      }
      if (res.data.data.imgurl) {
        imgurl.src = res.data.data.imgurl;
      }
      if (res.data.data.sign) {
        sign.textContent = res.data.data.sign;
      }
    }
  });

// 发送运动数据请求
axios
  .get("http://139.9.177.51:8099/users/mysportsBadge?userId=" + userId)
  .then(function (res) {
    console.log(res);
    if (res.data.status === 0) {
      // console.log(1);
      dynamicCount.textContent = res.data.data.dynamicCount + "条";
      times.textContent = res.data.data.sports.times;
      calorie.textContent = res.data.data.sports.calorie;
    }
  });

// 退出登录
loginOut.addEventListener("click", function () {
  weui.confirm("确定退出登录吗?", function () {
    localStorage.removeItem("userId");
    location.href = './login.html'
  
  });

});


// 跳转资料页面
information.addEventListener('click',function(){
    location.href = './information.html'
})
